home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / os2tools / bnklysrc / sb_scrl.c < prev    next >
Encoding:
Text File  |  1989-01-01  |  6.8 KB  |  175 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software <no-Inc>                   */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          No-Cost<no-tm> Software.                       */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello  */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*              Box Drawing subroutines for BinkleyTerm 2.10                */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.210.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU SHOULD  IMMEDIATELY CONTACT THE AUTHORS    */
  24. /*    AT THE  ADDRESSES LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO    */
  25. /*    USE   THIS  FILE  WITHOUT  HAVING   ACCEPTED  THE  TERMS  OF   THE    */
  26. /*    BINKLEYTERM  LICENSING AGREEMENT,  OR SUCH OTHER  AGREEMENT AS YOU    */
  27. /*    ARE ABLE TO REACH WITH THE AUTHORS.                                   */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /*    The Authors can be reached at the following addresses:                */
  31. /*                                                                          */
  32. /*    Robert C. Hartman                      Vincent E. Perriello           */
  33. /*    Spark Software                         VEP Software                   */
  34. /*    427-3 Amherst Street                   111 Carroll Street             */
  35. /*    CS2032, Suite 232                      Naugatuck, CT 06770            */
  36. /*    Nashua, NH 03061                                                      */
  37. /*                                                                          */
  38. /*    FidoNet 1:132/101                      FidoNet 1:141/491              */
  39. /*    Data    (603) 888-8179                 Data    (203) 729-7569         */
  40. /*                                                                          */
  41. /*    Please feel free to contact us at any time to share your comments     */
  42. /*    about our software and/or licensing policies.                         */
  43. /*                                                                          */
  44. /*                                                                          */
  45. /*   This module is derived from code developed by Augie Hansen in his      */
  46. /*   book "Proficient C" published by Microsoft Press.  Mr. Hansen was      */
  47. /*   kind enough to give us verbal permission to use his routines, and      */
  48. /*   Bob, Vince and Alan (and all our full screen users) are grateful.      */
  49. /*   If you decide to use this code in some package you are doing, give     */
  50. /*   some thought to going out and buying the book. He deserves that.       */
  51. /*                                                                          */
  52. /*--------------------------------------------------------------------------*/
  53.  
  54.  
  55. #include <string.h>
  56.  
  57. #ifdef __TURBOC__
  58. #include <mem.h>
  59. #else
  60. #include <memory.h>
  61. #endif
  62.  
  63. #include "sbuf.h"
  64. #include "com.h"
  65. #include "xfer.h"
  66. #include "zmodem.h"
  67. #include "keybd.h"
  68. #include "sched.h"
  69. #include "externs.h"
  70. #include "prototyp.h"
  71.  
  72. extern BUFFER Sbuf;
  73. extern CELLP Scrnbuf;
  74.  
  75. int sb_scrl (win, n)
  76. REGIONP win;
  77. int n;
  78. {
  79.    register int r, c;
  80.  
  81.    c = win->sc0;
  82.    if (n == 0)
  83.       {
  84.       /* clear the entire region to spaces */
  85.       sb_fillc (win, ' ');
  86.       }
  87.    else if (n > 0)
  88.       {
  89.       /* scroll n rows up */
  90.       for (r = win->sr0; r <= win->sr1 - n; r++)
  91.          {
  92.          memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r + n) * SB_COLS + c,
  93.                  (win->sc1 - win->sc0 + 1) * 2);
  94.          if (win->sc0 < Sbuf.lcol[r])
  95.             {
  96.             Sbuf.lcol[r] = win->sc0;
  97.             }
  98.          if (win->sc1 > Sbuf.rcol[r])
  99.             {
  100.             Sbuf.rcol[r] = win->sc1;
  101.             }
  102.          }
  103.       for (; r <= win->sr1; r++)
  104.          {
  105.          for (c = win->sc0; c <= win->sc1; c++)
  106.             {
  107.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  108.             }
  109.          if (win->sc0 < Sbuf.lcol[r])
  110.             {
  111.             Sbuf.lcol[r] = win->sc0;
  112.             }
  113.          if (win->sc1 > Sbuf.rcol[r])
  114.             {
  115.             Sbuf.rcol[r] = win->sc1;
  116.             }
  117.          }
  118.       }
  119.    else
  120.       {
  121.       /* scroll n rows down */
  122.       n = -n;
  123.       for (r = win->sr1; r >= win->sr0 + n; r--)
  124.          {
  125.          memcpy (Scrnbuf + r * SB_COLS + c, Scrnbuf + (r - n) * SB_COLS + c,
  126.                  (win->sc1 - win->sc0 + 1) * 2);
  127.          if (win->sc0 < Sbuf.lcol[r])
  128.             {
  129.             Sbuf.lcol[r] = win->sc0;
  130.             }
  131.          if (win->sc1 > Sbuf.rcol[r])
  132.             {
  133.             Sbuf.rcol[r] = win->sc1;
  134.             }
  135.          }
  136.       for (; r >= win->sr0; r--)
  137.          {
  138.          for (c = win->sc0; c <= win->sc1; c++)
  139.             {
  140.             (Scrnbuf + r * SB_COLS + c)->b.ch = ' ';
  141.             }
  142.          if (win->sc0 < Sbuf.lcol[r])
  143.             {
  144.             Sbuf.lcol[r] = win->sc0;
  145.             }
  146.          if (win->sc1 > Sbuf.rcol[r])
  147.             {
  148.             Sbuf.rcol[r] = win->sc1;
  149.             }
  150.          }
  151.       }
  152.  
  153.    Sbuf.flags |= SB_DELTA;
  154.  
  155.    return (SB_OK);
  156. }
  157.  
  158. int sb_set_scrl (win, top, left, bottom, right)
  159. REGIONP win;
  160. int top, left;
  161. int bottom, right;
  162. {
  163.    if ((top < 0) || (left < 0) ||
  164.        (bottom > win->r1 - win->r0) ||
  165.        (right > win->c1 - win->c0))
  166.       return (SB_ERR);
  167.  
  168.    win->sr0 = win->r0 + top;
  169.    win->sc0 = win->c0 + left;
  170.    win->sr1 = win->r0 + bottom - 1;
  171.    win->sc1 = win->c0 + right - 1;
  172.  
  173.    return (SB_OK);
  174. }
  175.